package com.zhou.common.mybatis.template.shiro.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.zhou.common.lib.model.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户信息表
 * </p>
 *
 * @author zxf
 * @since 2023-02-23
 */
@Getter
@Setter
@TableName("sys_user")
@ApiModel(value = "SysUser对象", description = "用户信息表")
public class SysUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "部门ID", position = 1)
    private Long deptId;

    @ApiModelProperty(value = "登录账号", position = 2)
    private String loginName;

    @ApiModelProperty(value = "用户昵称", position = 3)
    private String userName;

    @ApiModelProperty(value = "用户类型（00系统用户;01注册用户）", position = 4)
    private String userType;

    @ApiModelProperty(value = "用户邮箱", position = 5)
    private String email;

    @ApiModelProperty(value = "手机号码", position = 6)
    private String phonenumber;

    @ApiModelProperty(value = "用户性别（0男;1女 2未知）", position = 7)
    private String sex;

    @ApiModelProperty(value = "头像路径", position = 8)
    private String avatar;

    @ApiModelProperty(value = "密码", position = 9)
    private String password;

    @ApiModelProperty(value = "盐加密", position = 10)
    private String salt;

    @ApiModelProperty(value = "帐号状态（0正常;1停用）", position = 11)
    private String status;

    @ApiModelProperty(value = "最后登录IP", position = 12)
    private String loginIp;

    @ApiModelProperty(value = "最后登录时间", position = 12)
    private LocalDateTime loginDate;

    @ApiModelProperty(value = "密码最后更新时间", position = 13)
    private LocalDateTime pwdUpdateDate;

    @ApiModelProperty(value = "备注", position = 14)
    private String remark;


    public boolean isAdmin() {
        return isAdmin(this.getId());
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }


}
